package problems.solved;

import java.math.BigInteger;

public class Problem48 {
	public static void main(String[] args) {
		long sum = 0;
		for (int i = 1; i <= 1000; i++) {
			String text = BigInteger.valueOf(i).pow(i).toString();
			String lastTen = text.length() < 10 ? text : text.substring(text.length() - 10);
			sum += Long.parseLong(lastTen);
		}
		System.out.println("Last 10 digits of 1^1 + 2^2 + ... + 1000^1000 are " + sum % 10000000000L); // 9110846700
	}
}
